home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_01 / 9n01105b < prev    next >
Text File  |  1990-10-03  |  860b  |  25 lines

  1.  
  2.         pairs_inuse = argc/2;           /* number of patterns */
  3.         if (0 == (pairs = (pair *)malloc(pairs_inuse * sizeof(pair)))) {
  4.                 tcl_error("malloc(%d pairs)",pairs_inuse);
  5.                 return(TCL_ERROR);
  6.         }
  7.  
  8.         timeout_action = eof_action = 0;
  9.         for (i = 1, p = pairs;i<argc;i+=2,p++) {
  10.                 if (!(strcmp(argv[i],"timeout"))) {
  11.                         p->type = keyword;
  12.                         timeout_action = argv[i+1];
  13.                 } else if (!(strcmp(argv[i],"eof"))) {
  14.                         p->type = keyword;
  15.                         eof_action = argv[i+1];
  16.                 } else {
  17.                         p->type = pattern;
  18.                         p->pattern = argv[i];
  19.                         p->action = argv[i+1];
  20.                 }
  21.         }
  22.  
  23.         Listing 7
  24.  
  25.